/**
 * 管道
 *    1.转换 将前端传入的数据转成需要的数据
 *    2.验证 类似于前端的 rules 配置验证规则
 *
 *    八个内置转换API:
 *       ValidationPipe  ParseIntPipe:字符转整形  ParseFloatPipe  ParseBoolPipe   ParseArrayPipe  ParseUUIDPipe:验证是否是UUID  ParseEnumPipe  DefaultValuePipe
 */

import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  ParseIntPipe,
  ParseUUIDPipe,
} from '@nestjs/common';
import { PipelineService } from './pipeline.service';
import { CreatePipelineDto } from './dto/create-pipeline.dto';
import { UpdatePipelineDto } from './dto/update-pipeline.dto';

@Controller('pipeline')
export class PipelineController {
  constructor(private readonly pipelineService: PipelineService) {}

  // @Get(':id')
  // // 使用管道将字符串转整形
  // parseIntPipeTest(@Param('id', ParseIntPipe) id: number) {
  //   console.log(typeof id);
  //   return id;
  // }

  @Get(':id')
  // 使用管道验证是否是 uuid
  parseUUIDPipeTest(@Param('id', ParseUUIDPipe) id: number) {
    console.log(typeof id);
    return id;
  }
}
